package com.aidansmeaton.weightmanager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.RadioButton;

/** The first activity in the app. */
public class SetUpWeightTypeActivity extends Activity {
	
	// Personal
	private RadioButton imperialRadio;
	private RadioButton metricRadio;
    
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    	setContentView(R.layout.setup_weight_type);
        
        // Stop keyboard popping up automatically
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        
        setTitle("Setup - Weight Type");
        imperialRadio = (RadioButton) findViewById(R.id.imperial);
        metricRadio = (RadioButton) findViewById(R.id.metric);
        
        imperialRadio.setChecked(getSharedPreferences("Profile", 0).getBoolean("Imperial",true));
        metricRadio.setChecked(!imperialRadio.isChecked());
        
    }
    
	private void saveWeightType(){
		boolean isFemale = imperialRadio.isChecked();
		getSharedPreferences("Profile", 0).edit().putBoolean("Imperial", isFemale).commit();
	}
	
	public void nextClick(View v){
		saveWeightType();
		finish();
		Intent setupIntent = new Intent(this, SetUpStartWeightActivity.class);
		this.startActivity(setupIntent);
	}
	
	public void backClick(View v){
		saveWeightType();
		finish();
		Intent setupIntent = new Intent(this, SetUpExerciseActivity.class);
		this.startActivity(setupIntent);
	}
	
	public void laterClick(View v){
		finish();
	}
	
}